<!DOCTYPE html>

<html xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core">


<h:head>

	<style type="text/css">
.ui-layout,.ui-layout-doc,.ui-layout-unit,.ui-layout-wrap,.ui-layout-bd,.ui-layout-hd
	{
	border: none;
}

body {
	margin: 3% 7% 3% 7%;
}

.ui-widget,.ui-widget .ui-widget {
	font-size: 95%;
}

.ui-panelmenu-header,.ui-menuitem-text {
	font-size: 10pt
}

.companyHeaderGrid tr,.companyHeaderGrid td {
	border: none;
}
</style>

</h:head>

<h:body>

	<ui:composition>


		<h:form id="trasporto_filter_form">


			<p:panelGrid columns="4" style="min-width: 100%"
				styleClass="companyHeaderGrid">
				<f:facet name="header">  Filtra Trasporti  </f:facet>

				<h:outputLabel for="city_p" value="Citta Partenza: " />
				<p:autoComplete id="city_p"
					value="#{trasportoBean.datiFiltro.cittaPartenza}"
					label="Citta Partenza" completeMethod="#{cittaBean.complete}"
					var="c" itemLabel="#{c.name}" minQueryLength="3" itemValue="#{c}"
					forceSelection="true" converter="cittaConverter">

					<p:ajax event="itemSelect" update="city_p" />

				</p:autoComplete>

				<h:outputLabel for="city_a" value="Citta Arrivo: " />
				<p:autoComplete id="city_a"
					value="#{trasportoBean.datiFiltro.cittaArrivo}"
					label="Citta Partenza" completeMethod="#{cittaBean.complete}"
					var="c" itemLabel="#{c.name}" minQueryLength="3" itemValue="#{c}"
					forceSelection="true" converter="cittaConverter">

					<p:ajax event="itemSelect" update="city_a" />

				</p:autoComplete>

				<h:outputLabel for="dataPartenza" value="Data" />
				<p:calendar id="dataPartenza" label="Data Partenza"
					value="#{trasportoBean.datiFiltro.data}" showButtonPanel="true"
					pages="2" mindate="#{pacchettoBean.CURRENT_DATE}" immediate="true" />

				<f:facet name="footer">
					<p:commandButton value="Filtra" icon="ui-icon-check"
						style="margin:0" update=":tab_view_id:trasporto_list_form"
						actionListener="#{trasportoBean.filtraTrasporti}" />
				</f:facet>

			</p:panelGrid>
		</h:form>


		<h:form id="trasporto_list_form">
			<!-- START - Tabella dei trasporti -->

			<p:dataTable value="#{trasportoBean.listaTrasportiFiltrati}"
				var="trasporto" id="sb_trasporti_table" rowSelectMode="single"
				rows="20000" selectionMode="single" paginator="false"
				selection="#{trasportoBean.trasportoSelezionato}"
				rowKey="#{trasporto.cittaPartenza.name}" scrollable="true"
				liveScroll="true" scrollHeight="240">

				<!-- Definisco cosa deve fare con la selezione -->
				<p:ajax event="rowSelect"
					oncomplete="window.location.href='sb_trasporto_detail.xhtml'"
					listener="#{trasportoBean.onTrasportoRowSelect}" />



				<f:facet name="header"> Trasporti disponibili </f:facet>

				<p:column>
					<f:facet name="header"> Citta Partenza </f:facet>
									#{trasporto.cittaPartenza.name}
								</p:column>

				<p:column>
					<f:facet name="header"> Citta Arrivo </f:facet>
									#{trasporto.cittaArrivo.name}
								</p:column>

				<p:column>
					<f:facet name="header"> Data </f:facet>
									#{trasporto.dataAsString}
								</p:column>


				<p:column>
					<f:facet name="header"> Prezzo </f:facet>
									#{trasporto.prezzo}
								</p:column>

				<p:column>
					<f:facet name="header"> Disponibinlita </f:facet>
									#{trasporto.disponibilita}
								</p:column>

			</p:dataTable>

			<!-- END - Tabella dei trasporti -->

		</h:form>
	</ui:composition>


</h:body>
</html>